package click


class ClearLogJob {
    //def timeout = 5000l // execute job once in 5 seconds
    static triggers = {
        cron name: 'ClearLogTrigger', cronExpression: "0 0 */6 * * ?"
        //cron name: 'ClearLogTrigger', cronExpression: "0 * * * * ?"
    }

    def execute() {
        // execute task
        //println "#####################"
        def calendar=Calendar.getInstance();   

        calendar.add(Calendar.DAY_OF_YEAR  ,-2)
        log.info("quartz(Clear Log Job) batch delete Ip [delete Ip ip where ip.lastTime < ${calendar.getTime()}]" )
        Ip.executeUpdate("delete Ip ip where ip.lastTime < ? ", [calendar.getTime()])

    }
}
